
package receita;

import java.sql.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import oracle.jdbc.OracleDriver;


public class DBConnect {
  
      public static void main (String[] args) throws SQLException {

        ResultSet rset = null;
        Statement stmt = null;
        DBConnect s = new DBConnect();
        Connection con = s.getConnection();
        stmt = con.createStatement();

        rset = stmt.executeQuery("SELECT nm FROM Utentes WHERE tf = 912577684");
        while (rset.next()) {
           System.out.println(rset.getString(1));
        }
        rset.close();
        con.close();
        // TODO code application logic here
    }

    public java.sql.Connection getConnection() throws SQLException {


        // Load the database details into the variables.
        String url = "jdbc:oracle:thin:@" + "gia-oracle.di.uminho.pt" + ":" + "1521" + ":"
                + "OSIRIS";
        // Create the properties object that holds all database details
        Properties props = new Properties();
        props.put("user", "LEI2011_G10");
        props.put("password", "LEI2011_G10");
        props.put("SetBigStringTryClob", "true");
        // Load the Oracle JDBC driver class.
        DriverManager.registerDriver(new OracleDriver());
        Connection Con = null;
        // Get the database connection
        Con = DriverManager.getConnection(url, props);
        return Con;
    }


}